require.config({
  paths: {
    domReady: "vendor/domready/ready",
    react: "vendor/react/react",
    reactDom: "vendor/react/react-dom",
    backbone: "vendor/backbone/backbone",
    underscore: "vendor/underscore/underscore",
    jquery: "vendor/jquery/dist/jquery"
  }
});


// 错误捕捉
require.onError = function (err) {
    console.log(err.requireType);
    if (err.requireType === 'timeout') {
      console.log('modules: ' + err.requireModules);
    }
   throw err;
};

require([
  'domReady',
  'react',
  'reactDom',
  'backbone',
  './builder/js/index'
], function(domReady, React, ReactDom, Backbone, Index) {

  var Router = Backbone.Router.extend({
    routes: {
      "": "index",
      "users": "users"
    },
    index: function() {
      console.log('index');
      var index = ReactDom.render(
        React.createElement(Index),
        document.getElementById("container")
      )
    },
    users: function() {
      var users = ReactDom.render(
        React.createElement(Index),
        document.getElementById("container")
      )
    }
  })

  new Router();
  Backbone.history.start({pushState: true});
})
